/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package idea.de.explorer;


import idea.model.qnrlibrary.CustomResponseDeView;
import java.beans.IntrospectionException;
import java.util.List;
import org.openide.nodes.BeanNode;
import org.openide.nodes.ChildFactory;
import org.openide.nodes.Children;
import org.openide.nodes.Node;
import org.openide.util.Exceptions;
import org.openide.util.lookup.Lookups;


/**
 *
 * @author rejun001
 */
public class IDataElemsChildFactory extends ChildFactory<CustomResponseDeView>
{

    private List<CustomResponseDeView> resultList;


    public IDataElemsChildFactory( List<CustomResponseDeView> resultList )
    {
        this.resultList = resultList;
    }

    
    @Override
    protected boolean createKeys( List<CustomResponseDeView> list )
    {
        for (CustomResponseDeView crde : resultList) {
            list.add(crde);
        }
        return true;
    }


    @Override
    protected Node createNodeForKey( CustomResponseDeView key )
    {
        IDataElemsNode node = null;
        try
        {
            node = new IDataElemsNode(key);
        } catch ( Exception e )
        {
            Exceptions.printStackTrace( e );
        }
        
        return node;
    }
    
    private class IDataElemsNode extends BeanNode {
        
        public IDataElemsNode( CustomResponseDeView bean)  throws IntrospectionException {
            super( bean, Children.LEAF, Lookups.singleton( bean ) );
            //setDisplayName(bean.getDeName());
            setDisplayName(bean.getOccurrenceSequence().toString());
            setShortDescription(bean.getDeName() + "<br\\>" + bean.getPaperAgName());
        }           
    }    
}
